package chapter1.date.task;
/*
1：定义一个Map，通过value删除对应的键值对
 */

import java.util.*;

public class Task01 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Map<String, String> map = new HashMap<>();
        map.put("狗", "dog");
        map.put("蛇", "snake");
        map.put("蟒蛇", "python");
        map.put("老虎", "tiger");
        map.put("大猫", "cat");
        map.put("小猫", "cat");
        System.out.print("输入value值：");
        String s = input.next();
        if (map.containsValue(s)) {
            Set<Map.Entry<String, String>> entries = map.entrySet();
            Iterator<Map.Entry<String, String>> iter = entries.iterator();
            while (iter.hasNext()) {
                Map.Entry<String, String> entry = iter.next();
                if (entry.getValue().equals(s))
                    iter.remove();  
            }
            System.out.println(map);
        } else
            System.out.println("HashMap中无此value值");


    }
}
